import json

from langchain_core.prompts import ChatPromptTemplate

from utils.llm_generate import single_llm
from prompt.content_prompt import content_prompt
from utils.logger import LOG
from utils.outline_parser import outline_to_json, chapter2md
from utils.log import logger

def generate_section_content(text, outline):

    """
    根据文本内容和大纲生成小节内容
    :param text:
    :param outline:
    :return:
    """

    llm = single_llm
    prompt_template = ChatPromptTemplate([
        ("system", content_prompt),
        ("user", "{input}")
    ])
    text = text + "\n" + outline
    chain = prompt_template | llm
    logger.info(f"生成的内容如下:{chain.invoke(text).content}")
    return chain.invoke(text).content
